<template>
	<view class="container big-box">
		<top-navigation :isBack="true" bgColor="#17171F" isFix isShow>
			<view slot='center-slot' class="left-slot">
				注销帐号
			</view>
		</top-navigation>
		<view class="title">
			{{title}}
		</view>
		<view class="content">
			<u-parse :content="getContent"></u-parse>
		</view>
		<view class="btn-t justify-center align-center" @tap="signOut" v-if="!loading">
			我理解并同意注销
		</view>
		<view class="btn justify-center align-center" @tap="$navto('/pages/mine/setting/setting',false,4)"
			v-if="!loading">
			我再想想
		</view>
		<message-modal :isShow='captchaShow' @sendMobileCode='signOut'
			@close='captchaShow=false'></message-modal>
	</view>
</template>

<script>
	//在需要加、解码的的文件里引入【注意替换成自己的路径】
	import {
		Base64
	} from '@/utils/plugs/imgOrBase64.js';

	import messageModal from './messageModal/messageModal.vue'
	import validate from 'common/js/validate.js';
	import auth from 'common/js/auth.js';
	import globalConfig from '@/common/js/golbalConfig.js';
	// import {
	// 	randomString
	// } from '../../utils/libs.js'
	import base64Arraybuffer from 'base64-arraybuffer'
	export default {
		components: {
			messageModal
		},
		data() {
			return {
				captchaShow: false,
				type: 'user',
				content: '',
				title: '',
				loading: false,
			};
		},
		mixins: [auth, globalConfig],

		onLoad(option) {
			this.loading = true
			this.getStatic(true)
		},
		onShow() {

		},
		onReady() {
			// this.getStatic()
		},
		computed: {
			getContent() {
				if (this.content == '') {
					return ''
				}
				// var regex = /\s+src="([^"]*)"\s+style="([^"]*)">/g;
				// var match = regex.exec(this.goodsDetail.content);
				if (true) {
					// var src = match[1]; // 获取style属性的值
					// var style = match[2]; // 获取src属性的值
					// console.log("Style:", style);
					// console.log("Src:", src);
					return this.content
				} else {
					return this.content.replace(/style=/g,
						`style="width:100% !important;display:block;" src="${this.host}/`)
				}
			},
		},
		methods: {
			selectTab(v) {
				this.tabValue = v
			},
			signOut(e) {
				if(this.captchaShow){
					this.getStatic(false,e)
				}else{
					this.captchaShow = true
				}
			},
			// 方法
			async getStatic(isLogoff,e) {
				let url = '/api/v1/logoff'
				let reqData
				if(e){
					reqData = {
						captcha:e.captcha,
						rand_id:e.id
					}
				}else{
					reqData = {
						
					}
				}
				
				let request = isLogoff ? this.$getRequest : this.$postRequest
				let {
					code,
					msg,
					data
				} = await request(url,reqData)
				if (code == 200) {
					
					if (!isLogoff) {
						uni.clearStorageSync('token')
						this.$navto('/pages/login/app-login', false, 3)
					}else{
						console.log(data.content, '静态资源');
						this.content = data.content
						this.title = data.title
					}
				} else {
					this.$refs.uToast.show({
						message: msg
					})
				}
				this.loading = false
			},



		},

	};
</script>

<style>
	@import '/common/css/common.css';
</style>

<style lang="scss" scoped>
	body *,
	page view {
		box-sizing: border-box;
		flex-shrink: 0;
		line-height: 2;
	}

	.bg {
		position: fixed;
		width: 100vw;
		height: 671rpx;
		bottom: constant(safe-area-inset-bottom);
		bottom: env(safe-area-inset-bottom);
	}


	.popup-box {
		border-radius: 20rpx 20rpx 0 0;
		background-color: #1A2131;



		.popup-content {
			padding: 0 100rpx;
			text-align: center;
			font-size: 24rpx;
			color: #FFF;

			.user-read {
				margin: 0 10rpx;
				color: #3ADD8F;
			}
		}

		.popup-btn {
			margin-top: 70rpx;
			width: 616rpx;
			height: 62rpx;
			background: #27FF92;
			border-radius: 10rpx;
			color: #020600;
			font-size: 28rpx;

			&[disabled] {
				background-color: #f7f7f7 !important;
			}
		}

		.popup-btn-close {
			margin-top: 20rpx;
			height: 62rpx;
			background: #27FF9200;
			border-radius: 10rpx;
			color: #818591;
			font-size: 28rpx;

		}
	}




	.title {
		font-weight: 700;
		color: #fff;
		font-size: 36rpx;
		padding: 50rpx 50rpx 80rpx;
	}

	.btn-t {
		margin: 70rpx auto 0;
		height: 90rpx;
		width: 400rpx;
		border-radius: 8rpx;
		bottom: 120rpx;
		font-weight: 700;
		font-size: 30rpx;
		background-color: #3ADD8F;
		color: #000;
	}

	.btn {
		margin: 30rpx auto 0;
		height: 90rpx;
		width: 400rpx;
		border-radius: 8rpx;
		bottom: 120rpx;
		font-weight: 700;
		font-size: 30rpx;
		background-color: rgb(32, 32, 44);
		color: #FFF;
	}

	.big-box {
		width: 100vw;
		background: #17171F;
		min-height: 100vh;

		.left-slot {
			color: #FFF;
		}

		.content {
			padding: 0rpx 50rpx;
			color: rgba(255, 255, 255, .8);
			font-size: 28rpx;
		}
	}
</style>